# 一定要安装 4.0.0-rc1 版本，否则程序会报错：
# pip install googletrans==4.0.0-rc1

import googletrans as gt

trans = gt.Translator()

english = '''Inside the computer’s world, there is only data. 
You can read data, modify data, create new data—but that which isn’t data cannot be mentioned.
All this data is stored as long sequences of bits and is thus fundamentally alike.

Bits are any kind of two-valued things, usually described as zeros and ones. 
Inside the computer, they take forms such as a high or low electrical charge, a strong or weak signal, or a shiny or dull spot on the surface of a CD. 
Any piece of discrete information can be reduced to a sequence of zeros and ones and thus represented in bits.'''

chinese = trans.translate(english, dest='zh-CN', src='en')
chinese = chinese.text.replace('  ', ' ')

print('EN:', english)
print('CN:', chinese, end='\n\n')

news_titles = ['''C++ Modules: Packaging Story (conan.io)''',
	'''4K4D: Real-Time 4D View Synthesis at 4K Resolution (zju3dv.github.io)''',
	'''Higher Quality Random Floats (corsix.org)''',
	'''Psytrance Guide (psytranceguide.com)''',
	'''Google opens Falcon, a reliable low-latency hardware transport, to the ecosystem (cloud.google.com)''',
	'''Using spaced repetition systems to see through a piece of mathematics (2019) (cognitivemedium.com)''',
	'''The Long Boom: A History of the Future, 1980–2020 (1997) (wired.com)''',
	'''Barnes and Noble Sets Itself Free (nytimes.com)''',
	'''The pneumatic tube mail system in New York City (untappedcities.com)''',
	'''Qaul – Internet independent wireless mesh communication app (qaul.net)''',
	'''Localization Failure: Temperature Is Hard (randomascii.wordpress.com)''',
	'''Levity and gravity (nature.com)''',
	'''Superlinear Returns (paulgraham.com)''',
	'''Why Card Catalogs Matter (2017) (smithsonianmag.com)''',
	'''Frasier Fantasy (edward-la-barbera.itch.io)''',
	'''NASA's Psyche Spacecraft, Optical Comms Demo En Route to Asteroid (nasa.gov)''',
	'''Don't work with assholes (danielrsim.com)''',
	'''WordStar: Arrogant, Difficult, Powerful (2022) (abortretry.fail)''',
	'''Reconfigurable transistors for more efficient AI on-device classification (northwestern.edu)''',
	'''Grayjay – Follow Creators Not Platforms (grayjay.app)''',
	'''Llemma: An Open Language Model for Mathematics (arxiv.org)''',
	'''Free IRS-run tax filing pilot to be available in 13 states (irs.gov)''',
	'''Qualcomm to Bring RISC-V Based Wearable Platform to Wear OS by Google (qualcomm.com)''',
	'''Nushell 0.86 (nushell.sh)''',
	'''ExecuTorch: Run PyTorch programs on mobile and edge devices (pytorch.org)''',
]

for english in news_titles:
    chinese = trans.translate(english, dest='zh-CN', src='en')
    chinese = chinese.text.replace('  ', ' ')

    print('EN:', english)    
    print('CN:', chinese, end='\n\n')

